Skip to content

Refactor: Enhance Spotify Optimistic UI Architecture - #9664

Merged
arii merged 5 commits into
refactor/spotify-optimistic-ui-11189282566171114552from
refactor-spotify-optimistic-ui-11189282566171114552-18426785454480979537
Mar 26, 2026
Merged

Refactor: Enhance Spotify Optimistic UI Architecture#9664
arii merged 5 commits into
refactor/spotify-optimistic-ui-11189282566171114552from
refactor-spotify-optimistic-ui-11189282566171114552-18426785454480979537

Conversation

@arii

@arii arii commented Mar 23, 2026

Copy link
Copy Markdown
Owner

This commit refines the previous PR's approach to the client-optimistic Spotify syncing architecture. It resolves the duplicate logic introduced in AudioContext.tsx by properly extracting the preferences hook into its own file. It also resolves a desync where optimistic UI failures would artificially lock the client for 2 seconds. The SpotifyPlayerManager now correctly emits a `SPOTIFY_OPTIMISTIC_FAILURE` event that `useSpotifyVolume` intercepts to instantly unlock the slider. Furthermore, redundant states and boilerplate throttle logic from `SpotifyControls` have been completely stripped out to rely solely on `useSpotifyVolume`. UI sizing logic in `VolumeSlider` is now natively using `theme.spacing()` instead of custom pixel multiplication values.


PR created automatically by Jules for task 18426785454480979537 started by @arii

- Moved duplicated context logic out of AudioContext to hooks/useAudioPreference.ts
- Refactored SpotifyControls to fully utilize useSpotifyVolume, removing duplicated local state
- Extracted scaling logic in VolumeSlider to leverage MUI theme.spacing instead of a manual scaleFactor
- Removed stale constants and updated syncing locks
- Updated spotifyPlayerManager executeOptimistic to emit failure events, unlocking useSpotifyVolume UI freeze early
- Cleaned up redundant verbose comments in SpotifyControls

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Moved duplicated context logic out of AudioContext to hooks/useAudioPreference.ts
- Refactored SpotifyControls to fully utilize useSpotifyVolume, removing duplicated local state
- Extracted scaling logic in VolumeSlider to leverage MUI theme.spacing instead of a manual scaleFactor
- Removed stale constants and updated syncing locks
- Updated spotifyPlayerManager executeOptimistic to emit failure events, unlocking useSpotifyVolume UI freeze early
- Cleaned up redundant verbose comments in SpotifyControls

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

👋 Welcome to HRM!

Thanks for your contribution. This repository uses Gemini AI for automated triage, code review, and generation.

🤖 Gemini Manual Trigger Quick Reference

Command Action
@gemini-bot Run AI Code Review (PR only)
@gemini-enrich Run PR Enrichment (PR only)
@gemini-triage Run Issue Triage
@gemini-coder <task> Generate Code
@create-review-issues Create issues from review (PR only)
@gemini-help Show this help message
@pr-squash Squash PR commits (PR only)
@conflict-resolve Resolve merge conflicts (PR only)

For more details and GitHub CLI examples, see the Manual Trigger Guide.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Review Skipped

Review was skipped for the following reason: Gemini review is globally disabled

🤖 Gemini Manual Trigger Guide

@arii arii added the not reviewed The review could not be performed or completed successfully. label Mar 23, 2026
- Restored \`sendVolumeCommand\` inside \`SpotifyControls\` to avoid ReferenceError when calling \`useSpotifyVolume\`.
- Cleaned up broken / duplicate tests and restored unit testing for \`SpotifyControls\` and \`SpotifyDisplay\` by correctly mocking \`useSpotifyCommand\` and \`useSpotifyVolume\`.
- Added missing \`SPOTIFY_OPTIMISTIC_FAILURE\` ServerMessage type mapping.
- Added \`onEvent\` explicitly to \`WebSocketContextType\` signature and exposed it in \`WebSocketProvider\`.
- Addressed leftover \`any\` typings reported by strict \`knip\` & TS type checks.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Review Skipped

Review was skipped for the following reason: Gemini review is globally disabled

🤖 Gemini Manual Trigger Guide

@arii arii added not reviewed The review could not be performed or completed successfully. and removed not reviewed The review could not be performed or completed successfully. labels Mar 23, 2026
- Fix missing strict typings for the onEvent custom hook mapping.
- Change `any` typings to `unknown` to satisfy strict ts checks.
- Add optional chaining property accesses.
- Run prettier and lint --fix to ensure codebase standards.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Review Skipped

Review was skipped for the following reason: Gemini review is globally disabled

🤖 Gemini Manual Trigger Guide

@arii arii added not reviewed The review could not be performed or completed successfully. and removed not reviewed The review could not be performed or completed successfully. labels Mar 23, 2026
- Removed `fix-lint.js`, `fix-tests.js`, and `fix-volume.js` from the repository root as they were causing Knip checks to fail by tracking unused files.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Review Skipped

Review was skipped for the following reason: Gemini review is globally disabled

🤖 Gemini Manual Trigger Guide

@arii arii added not reviewed The review could not be performed or completed successfully. and removed not reviewed The review could not be performed or completed successfully. labels Mar 24, 2026
@arii
arii marked this pull request as ready for review March 26, 2026 03:00
@arii
arii merged commit 0c65504 into refactor/spotify-optimistic-ui-11189282566171114552 Mar 26, 2026
29 checks passed
@arii
arii deleted the refactor-spotify-optimistic-ui-11189282566171114552-18426785454480979537 branch March 26, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not reviewed The review could not be performed or completed successfully.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant